package com.justgame.project.base.utils;

import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * 订单工具
 *
 * @author ZhouWeiBo
 */
public class OrderUtil {

    /**
     * 生成一个随机的站内订单号
     *
     * @return String
     */
    public static String buildStationOrderCode() {
        return "J" + new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) + "R" + new Random().nextInt(999999);
    }

    /**
     * 生成一个随机的支付VIP服务的订单号
     *
     * @return String
     */
    public static String buildVipOrderCode() {
        return "J" + new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) + "V" + new Random().nextInt(999999);
    }



    /* 第四方支付平台：站长付；http://www.zhanzhangfu.xyz/ */
    @Data
    public static class PayRequestModel {
        private float price;
        private String name = "";
        private String reurl = "";
        private String thirduid = "";
        private String paytype = "";
        private String remarks = "";
        private String other = "";
        private String callbackurl = "";
    }


    @Data
    public static class PayResponseModel {
        private String orderId;
        private String originalprice;
        private String price;
        private String name;
        private Integer paytype;
        private String other;
        private String remarks;
        private String thirduid;
        private String reurl;
        private String wxcode;
        private String zfbcode;
        private String qqcode;
        private String qrcode;
        private String zfbuseridcode;
    }

    /**
     * 生成支付订单必要参数
     * @return String
     */
    public static String buildPayOrderParams(PayRequestModel requestModel) {

        return null;
    }

    public static String randomNumberStr(int len){
        StringBuilder code = new StringBuilder();
        Random random = new Random();
        for (int i = 0; i < len; i++) {
            int r = random.nextInt(10);
            code.append(r);
        }
        return code.toString();
    }
}
